import 'package:device_info/device_info.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_ok/util/util.dart';
import 'package:get/get.dart';
import 'package:package_info/package_info.dart';

class Global {
  /// RELEASE-生产, TEST-测试环境, DEV-开发环境
  static const BuildType buildType = BuildType.RELEASE;

  /// Android设备信息
  static AndroidDeviceInfo androidDeviceInfo;

  /// iOS设备信息
  static IosDeviceInfo iosDeviceInfo;

  /// 包信息
  static PackageInfo packageInfo;

  /// init
  static Future<void> init() async {
    WidgetsFlutterBinding.ensureInitialized();

    if (GetPlatform.isAndroid) {
      //android状态栏透明
      SystemChrome.setSystemUIOverlayStyle(
          SystemUiOverlayStyle(statusBarColor: Colors.transparent));
      androidDeviceInfo = await DeviceInfoPlugin().androidInfo;
    } else if (GetPlatform.isIOS) {
      iosDeviceInfo = await DeviceInfoPlugin().iosInfo;
    }

    packageInfo = await PackageInfo.fromPlatform();

    await SpUtil.getInstance();
  }

  /// BaseUrl
  static String getBaseUrl() {
    switch (buildType) {
      case BuildType.RELEASE:
        return "";
      case BuildType.TEST:
        return "";
      case BuildType.DEV:
        return "";
    }
    return "";
  }
}

enum BuildType { RELEASE, TEST, DEV }
